|
In numerical analysis, a branch of mathematics, there are several square root algorithms or methods of computing the principal square root of a nonnegative real number. For the square roots of a negative or complex number, see below. Finding is the same as solving the equation . Therefore, any general numerical root-finding algorithm can be used. Newton's method, for example, reduces in this case to the so-called Babylonian method: : Generally, these methods yield approximate results. To get a higher precision for the root, a higher precision for the square is required and a larger number of steps must be calculated. == Rough estimation == Many square root algorithms require an initial seed value. If the initial seed value is far away from the actual square root, the algorithm will be slowed down. It is therefore useful to have a rough estimate, which may be very inaccurate but easy to calculate. With expressed in scientific notation as where and ''n'' is an integer, the square root can be estimated as : The factors two and six are used because they approximate the geometric means of the lowest and highest possible values with the given number of digits: and . For , the estimate is . When working in the binary numeral system (as computers do internally), by expressing as where , the square root can be estimated as , since the geometric mean of the lowest and highest possible values is . For the binary approximation gives These approximations are useful to find better seeds for iterative algorithms, which results in faster convergence. == Babylonian method == Perhaps the first algorithm used for approximating is known as the Babylonian method, named after the Babylonians,〔There is no direct evidence showing how the Babylonians computed square roots, although there are informed conjectures. (Square root of 2#Notes gives a summary and references.)〕 or "Hero's method", named after the first-century Greek mathematician Hero of Alexandria who gave the first explicit description of the method. It can be derived from (but predates by 16 centuries) Newton's method. The basic idea is that if is an overestimate to the square root of a non-negative real number then will be an underestimate and so the average of these two numbers may reasonably be expected to provide a better approximation (though the formal proof of that assertion depends on the inequality of arithmetic and geometric means that shows this average is always an overestimate of the square root, as noted in the article on square roots, thus assuring convergence). More precisely, if is our initial guess of and is the error in our estimate such that , then we can expand the binomial and solve for : since . Therefore, we can compensate for the error and update our old estimate as : Since the computed error was not exact, this becomes our next best guess. The process of updating is iterated until desired accuracy is obtained. This is a quadratically convergent algorithm, which means that the number of correct digits of the approximation roughly doubles with each iteration. It proceeds as follows: #Begin with an arbitrary positive starting value (the closer to the actual square root of , the better). #Let be the average of and (using the arithmetic mean to approximate the geometric mean). #Repeat step 2 until the desired accuracy is achieved. It can also be represented as: : : : This algorithm works equally well in the s, but cannot be used to identify real square roots with -adic square roots; one can, for example, construct a sequence of rational numbers by this method that converges to +3 in the reals, but to −3 in the 2-adics. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Methods of computing square roots」の詳細全文を読む スポンサード リンク
|